package com.lineage.server.datatables.lock;

import com.lineage.server.datatables.sql.BoardOrimTable;
import com.lineage.server.datatables.storage.BoardOrimStorage;
import com.lineage.server.templates.L1Rank;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class BoardOrimReading {
  private final Lock _lock = new ReentrantLock(true);
  
  private final BoardOrimStorage _storage = (BoardOrimStorage)new BoardOrimTable();
  
  private static BoardOrimReading _instance;
  
  public static BoardOrimReading get() {
    if (_instance == null)
      _instance = new BoardOrimReading(); 
    return _instance;
  }
  
  public void load() {
    this._lock.lock();
    try {
      this._storage.load();
    } finally {
      this._lock.unlock();
    } 
  }
  
  public List<L1Rank> getTotalList() {
    List<L1Rank> tmp;
    this._lock.lock();
    try {
      tmp = this._storage.getTotalList();
    } finally {
      this._lock.unlock();
    } 
    return tmp;
  }
  
  public int writeTopic(int score, String leader, List<String> partyMember) {
    this._lock.lock();
    int tmp = 0;
    try {
      tmp = this._storage.writeTopic(score, leader, partyMember);
    } finally {
      this._lock.unlock();
    } 
    return tmp;
  }
  
  public void renewPcName(String oriName, String newName) {
    this._lock.lock();
    try {
      this._storage.renewPcName(oriName, newName);
    } finally {
      this._lock.unlock();
    } 
  }
}
